﻿using System.Linq;
using WholesaleOnline.DataContract.View;
using WholesaleOnline.Model;

namespace WholesaleOnline.DataContract.Extension
{
    public static class CategoryExtension
    {
        public static CategoryView ConvertToCategoryView(this WoAttribute attribute)
        {
            return new CategoryView
            {
                Id = attribute.Id.ToString(),
                Name = attribute.Name,
                ChildList = attribute.Children.Select(c => c.ConvertToCategoryView())
            };
        }
    }
}
